#include <regx52.h>
#include "Delay.h"
#include "Key.h"
#include "Timer0.h"
#include "LCD1602.h"


unsigned char Hour=23;
unsigned char Minute=59;
unsigned char Second=55;
 void main()
 {
	 LCD_Init();
	 Timer0_Init();
	 while(1)
		{
			
			LCD_ShowString(1,1,"Clock:");
			LCD_ShowChar(2,3,':');
			LCD_ShowChar(2,6,':');
			LCD_ShowNum(2,1,Hour,2);
			LCD_ShowNum(2,4,Minute,2);
			LCD_ShowNum(2,7,Second,2);
			
		}
 }
 
//定时器0中断函数模板
	void Timer0_Routine() interrupt 1
{
	static unsigned int a=0;
	
	TL0 = 0x66;		//设置定时初值
	TH0 = 0xFC;		//设置定时初值	
	a++;
	if(a==1000)
		{
			a=0;
			Second++;
			if(Second==60)
			{
				Second=0;
				Minute++;
				if(Minute==60)
				{
					Minute=0;
					Hour++;
					if(Hour==24)
					{
						Hour=0;
					}
				}
			}
			
		}
	
}
